<template>
	<view class="all">
		<view class="usermsg">
			<u-modal :show="show2"  :content='content2' showCancelButton confirmText='去认证'
				@confirm="goAuth()" @cancel="cancel2()"></u-modal>
			<u-modal :show="show3"  style="text-align: center;" :content='content3' showCancelButton confirmText='确认'
				@confirm="goLoginOut()" @cancel="cancel3()"></u-modal>
			<view class="Id" @click="toMyid()">
				<view class="left">
					个人资料
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
			<view class="binding" @click="toBinding()">
				<view class="left">
					账号绑定
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
			<view class="realName" @click="toauth()">
				<view class="left">
					机构认证
				</view>
				<view class="right iconfont" v-if="!authed">
					未认证&nbsp;&nbsp; &#xe60d;
				</view>
				<view class="right iconfont" v-else>
					已认证&nbsp;&nbsp; &#xe60d;
				</view>
			</view>
			<view class="changePwd" @click="changePWD()" v-if="status">
				<view class="left">
					修改密码
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
		</view>
		<view class="operation" v-if="status">
			<view class="destory" @click="paySetting()">
				<view class="left">
					支付设置
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
		</view>
		<view class="policy">
			<view class="privacy" @click="toPolicy()">
				<view class="left">
					隐私政策
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
			<view class="question" @click="toQuestions()">
				<view class="left">
					常见问题
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
			<view class="idea" v-if="status" @click="toidea()">
				<view class="left">
					意见反馈
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
		</view>
		<view class="us">
			<view class="about" @click="toAbout()">
				<view class="left">
					关于我们
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
			<view class="version">
				<view class="left">
					当前版本
				</view>
				<view class="right iconfont">
					v1.0.0 &nbsp;&nbsp;&#xe60d;
				</view>
			</view>
		</view>
		<view class="operation" v-if="status">
			<view class="destory" @click="destory">
				<view class="left">
					注销账号
				</view>
				<view class="right iconfont">
					&#xe60d;
				</view>
			</view>
		</view>
		<view class="out" @click="goOut()" v-if="status">
			安全退出
		</view>
	</view>
</template>

<script>
	import {safeWithdrawing} from '@/utils/api.js'
	export default {
		data() {
			return {
				status: true,
				show2: false,
				show3: false,
				content2: '账号未实名认证认证完成后可以进行操作',
				content3:'确定要退出登录吗？',
				authed: true,
				token: '',

			}
		},
		onShow() {
			//监听退出返回 重新加载页面数据
			  uni.$on("getlist", (e)=>{
				  console.log('ooooooo');
				  this.userInfo={}
				  this.token=''
				  this.status=false
			     }) 
			try {
				const userInfo = uni.getStorageSync('user');
				console.log(userInfo,'userInfo');
				if (userInfo) {
					this.status = true
					this.userInfo = userInfo
					this.authed = this.userInfo.data[0].status
					this.token = userInfo.api_token
				}
			} catch (e) {

			}
		},
		onUnload() {
			// 清除监听
			uni.$off('getlist');
			uni.$emit("getPersonList",{})
		},
		methods: {
			goAuth() {
				// uni.navigateTo({
				// 	url: '/pages/person/authentication/uplode'
				// })
			},
			toBinding() {
				uni.navigateTo({
					url: '/pages/my/setting/binding/binding'
				})
			},
			paySetting() {
				uni.navigateTo({
					url: '/pages/my/setting/paySetting/paySetting'
				})
				// if (this.authed) {
				// 	uni.navigateTo({
				// 		url: '/pages/person/settings/paySetting'
				// 	})
				// } else {
				// 	this.show2 = true
				// }

			},
			toPolicy() {
				uni.navigateTo({
					url: '/pages/my/setting/privacy'
				})
			},
			toQuestions() {
				uni.navigateTo({
					url: '/pages/my/setting/questions/questions'
				})
			},
			toidea() {
				uni.navigateTo({
					url: '/pages/my/setting/suggestion/suggestion'
				})
			},
			toAbout() {
				uni.navigateTo({
					url: '/pages/my/setting/aboutUs'
				})
			},
			goback() {
				// uni.navigateTo({
				// 	url: '/pages/person/person'
				// })
			},
			toMyid() {
				uni.navigateTo({
					url: '/pages/my/setting/userInfo'
				})
				// if (this.status) {
				// 	uni.navigateTo({
				// 		url: '/pages/person/myAccount'
				// 	})
				// } else {
				// 	uni.navigateTo({
				// 		url: '/pages/my/setting/userInfo'
				// 	})
				// }

			},
			changePWD() {
				uni.navigateTo({
					url: '/pages/my/setting/changePWD'
				})
			},
			toauth() {
				uni.navigateTo({
					url:'/pages/my/setting/orgAuth/orgAuth'
				})
				// if (this.status) {
				// 	if (this.authed == 0) {
				// 		uni.navigateTo({
				// 			url: '/pages/person/authentication/uplode'
				// 		})
				// 	} else {
				// 		uni.navigateTo({
				// 			url: '/pages/person/authentication/authened'
				// 		})
				// 	}
				// } else {
				// 	uni.navigateTo({
				// 		url: '/pages/login/login'
				// 	})
				// }
			},
			toPhone() {
				// if (this.status) {
				// 	uni.navigateTo({

				// 	})
				// } else {
				// 	uni.navigateTo({
				// 		url: '/pages/login/login'
				// 	})
				// }
			},
			goOut() {
				this.show3=true
			},
			goLoginOut(){
				safeWithdrawing().then(res=>{
					console.log();
					uni.clearStorage();
					this.show3 = false
					uni.navigateTo({
						url: '/pages/login/login'
					})
				})
				// uni.request({
				// 	url: 'https://www.ghhlkj.com/api/safeWithdrawing',
				// 	header: {
				// 		'Authorization': 'Bearer' + this.token
				// 	},
				// 	method: 'POST',
				// 	success: (res) => {
				// 		console.log(res,'?????????????????');
						
				// 	}
				// })
				
			},
			destory() {
				uni.navigateTo({
					url:'/pages/my/setting/destory'
				})
			},
			cancel2() {
				this.show2 = false
			},
			cancel3() {
				this.show3 = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.all {
		background-color: #f6f6f6;
		padding-top: 5px;

		.usermsg {
			background-color: #ffffff;

			.Id,
			.binding,
			.realName,
			.changePwd {
				padding: 0 10px;
				font-size: 16px;
				height: 55px;
				line-height: 55px;
				font-weight: Medium;
				display: flex;
				justify-content: space-between;
				border-bottom: 0.5px #f6f6f6 solid;
			}
		}

		.policy {
			background-color: #ffffff;
			margin-top: 24rpx;

			.privacy,
			.question,
			.idea {
				padding: 0 10px;
				font-size: 16px;
				height: 55px;
				line-height: 55px;
				font-weight: Medium;
				display: flex;
				justify-content: space-between;
				border-bottom: 0.5px #f6f6f6 solid;
			}
		}

		.us {
			background-color: #ffffff;
			margin-top: 24rpx;

			.about,
			.version {
				padding: 0 10px;
				font-size: 16px;
				height: 55px;
				line-height: 55px;
				font-weight: Medium;
				display: flex;
				justify-content: space-between;
				border-bottom: 0.5px #f6f6f6 solid;
			}
		}

		.operation {
			background-color: #ffffff;
			margin-top: 24rpx;

			.destory {
				padding: 0 10px;
				font-size: 16px;
				height: 55px;
				line-height: 55px;
				font-weight: Medium;
				display: flex;
				justify-content: space-between;
				border-bottom: 0.5px #f6f6f6 solid;
			}
		}

		.out {
			margin-top: 30px;
			background-color: #ffffff;
			height: 60px;
			line-height: 60px;
			text-align: center;
			font-size: 18px;
		}
	}
</style>